@extends('layouts.header')
@section('style')
    .myHead{
    overflow: hidden;
    position: relative;
    }
    .myHead::before{
    content: '';
    position: absolute;
    width: 1px;
    height: 210px;
    top: 0;
    left: 0;
    background-color: #ccc;
    opacity: 0.5;
    display: block;
    transform: rotate(-74deg);
    transform-origin: top;
    overflow: hidden;
    }
    .myHead span:first-child{
    padding-left: 100px;
    }
    .myHead span:last-child{
    padding-right: 100px;
    }
@endsection
@section('content')
    <article class="page-container">
        <div id="tab_demo" class="HuiTab">
            <div class="tabBar clearfix"><span>基础设置</span><span class="ml-5">其他设置</span><span class="ml-5">安全</span></div>
            <div class="tabCon">
                <form class="form form-horizontal" id="form" autocomplete="off">
                    <div class="row cl">
                        <label class="form-label col-sm-3">网站名称：</label>
                        <div class="formControls col-sm-9">
                            <input type="text" class="input-text" value="{{ $data->name_site }}" placeholder="" name="name_site" autofocus="autofocus">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">检测公司名称（检测报告）：</label>
                        <div class="formControls col-sm-9">
                            <input type="text" class="input-text" value="{{ $data->name_rep }}" placeholder="" name="name_rep" autofocus="autofocus">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">检测公司名称（合格证）：</label>
                        <div class="formControls col-sm-5">
                            <input type="text" class="input-text" value="{{ $data->name_pass }}" placeholder="" name="name_pass">
                        </div>
                        <div class="formControls col-sm-4 c-blue">
                            换行加"/"
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">报告编号前缀：</label>
                        <div class="formControls col-sm-9">
                            <input type="text" class="input-text" value="{{ $data->report_num_pre }}" placeholder="" name="report_num_pre">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">样品号位数：</label>
                        <div class="formControls col-sm-9 skin-minimal">
                            <div class="radio-box">
                                <input type="radio" id="radio-1" name="chars_count" value="3" @if ($data->chars_count==3)checked @endif>
                                <label for="radio-1">3 位</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" id="radio-2" name="chars_count" value="4" @if ($data->chars_count==4)checked @endif>
                                <label for="radio-2">4 位</label>
                            </div>
                            <label style="color: #999!important;">如果您一个批次的样品数量会超过 999 件，请选择 4 位。3 位对应的条形码为 9 位，4 位对应的条形码为 10 位</label>
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">启用工器具ID：</label>
                        <div class="formControls col-sm-9 skin-minimal">
                            <div class="check-box">
                                <input type="checkbox" id="enable_tool_ID" name="enable_tool_ID" value="1" @if ($data->enable_tool_ID==1)checked @endif>
                                <label for="enable_tool_ID">启用</label>
                            </div>
                            <label style="color: #999!important;">不了解此功能的用户不要启用</label>
                        </div>
                    </div>
                <!--<div class="row cl">
                        <label class="form-label col-sm-3"></label>
                        <div class="formControls col-sm-9 c-blue">
                   ------------  报告模板文件  ------------
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">封面（批次报告）：</label>
                        <div class="formControls col-sm-9">
                        <span class="btn-upload form-group">
                            <input class="input-text upload-url radius" type="text" readonly placeholder="后缀必须为“.xls”">
                            <a href="" class="btn btn-primary radius">浏览</a>
                            <input type="file" name="file_fm" class="input-file" accept="application/vnd.ms-excel">
                        </span>
                        @if ($exist_template_fm)
                            <a class="btn btn-primary radius ml-20"
                               onclick="location.href='/{{config('constant.name_admin')}}/excelPos/downLoadTemplateFMFD?FMFD=封面'">
                                <i class="Hui-iconfont Hui-iconfont-down"></i> 下载封面模板</a>
                        @endif
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">封面（样品）：</label>
                        <div class="formControls col-sm-9">
                        <span class="btn-upload form-group">
                            <input class="input-text upload-url radius" type="text" readonly placeholder="后缀必须为“.xls”">
                            <a href="" class="btn btn-primary radius">浏览</a>
                            <input type="file" name="solo_file_fm" class="input-file" accept="application/vnd.ms-excel">
                        </span>
                        @if ($exist_template_solo_fm)
                            <a class="btn btn-primary radius ml-20"
                               onclick="location.href='/{{config('constant.name_admin')}}/excelPos/downLoadTemplateFMFD?FMFD=单样品封面'">
                                <i class="Hui-iconfont Hui-iconfont-down"></i> 下载样品封面模板</a>
                        @endif
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">封底：</label>
                        <div class="formControls col-sm-9">
                        <span class="btn-upload form-group">
                            <input class="input-text upload-url radius" type="text" readonly placeholder="后缀必须为“.xls”">
                            <a class="btn btn-primary radius">浏览</a>
                            <input type="file" name="file_fd" class="input-file" accept="application/vnd.ms-excel">
                        </span>
                        @if ($exist_template_fd)
                            <a class="btn btn-primary radius ml-20"
                               onclick="location.href='/{{config('constant.name_admin')}}/excelPos/downLoadTemplateFMFD?FMFD=封底'">
                                <i class="Hui-iconfont Hui-iconfont-down"></i> 下载封底模板</a>
                        @endif
                        </div>
                    </div>-->
                    @csrf
                    <div class="row cl pt-20">
                        <div class="col-sm-9 col-sm-offset-3">
                            <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                        </div>
                    </div>
                </form>
            </div>
            <div class="tabCon">
                <form class="form form-horizontal" id="form2" autocomplete="off">
                    <div class="row cl">
                        <label class="form-label col-sm-3">样品项目定价：</label>
                        <div class="formControls col-sm-5">
                            <label>
                                <input type="checkbox" name="set_other[open_price][value]" value="1" @if(data_get($setSys,'open_price','') == 1) checked @endif> 开启
                            </label>
                            <input type="hidden" value="样品项目定价：1开启" name="set_other[open_price][remark]">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">委托单位默认值：</label>
                        <div class="formControls col-sm-5">
                            <input type="text" class="input-text" value="{{$setSys
                            ['entrusted_company_default'] ?: ''}}" placeholder="" name="set_other[entrusted_company_default][value]" autofocus="autofocus">
                            <input type="hidden" value="委托单位默认值" placeholder="" name="set_other[entrusted_company_default][remark]" autofocus="autofocus">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">中控平台标题：</label>
                        <div class="formControls col-sm-5">
                            <input type="text" class="input-text" value="{{isset($setSys
                            ['zks_title']) ? $setSys
                            ['zks_title'] : '保定汇邦安全工器具检测中控平台'}}" placeholder="" name="set_other[zks_title][value]" autofocus="autofocus">
                            <input type="hidden" value="中控平台标题" placeholder="" name="set_other[zks_title][remark]" autofocus="autofocus">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">编码规则：</label>
                        <div class="formControls col-sm-7 bg-dark">
                            <div class="row cl">
                                <label class="form-label col-sm-2">24位编码规则：</label>
                                <div class="formControls col-sm-9 skin-minimal">
                                    <table class="table table-border table-bordered table-hover table-bg table-responsive">
                                        <thead class="text-c">
                                        <tr>
                                            <td>组成类别</td>
                                            <td>公司代码段</td>
                                            <td>识别码</td>
                                            <td>流水号</td>
                                            <td>校验码</td>
                                        </tr>
                                        </thead>
                                        <tbody class="text-c">
                                        <tr>
                                            <td>编码位数</td>
                                            <td>3</td>
                                            <td>2</td>
                                            <td>18</td>
                                            <td>1</td>
                                        </tr>
                                        <tr>
                                            <td>数值</td>
                                            <td class="{{data_get($setSys,'gqj_com_code','') ?: 'danger'}}">
                                                <input type="text" name="set_other[gqj_com_code][value]" value="{{data_get($setSys,'gqj_com_code','') ?: ''}}" class="input-text text-c">
                                                <input type="hidden" value="编码规则-公司代码段" placeholder="" name="set_other[gqj_com_code][remark]">
                                            </td>
                                            <td>
                                                <input type="text" name="set_other[gqj_scode][value]" value="{{data_get($setSys,'gqj_scode','') ?: '08'}}" class="input-text text-c">
                                                <input type="hidden" value="编码规则-识别码-电力安全工器具编码识别码为 08" placeholder="" name="set_other[gqj_scode][remark]">
                                                <i>电力安全工器具编码识别码为 08</i>
                                            </td>
                                            <td>见下表</td>
                                            <td>校验产生</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="row cl">
                                <label class="form-label col-sm-2">承上18位流水码规则：</label>
                                <div class="formControls col-sm-9 skin-minimal">
                                    <table class="table table-border table-bordered table-hover table-bg table-responsive">
                                        <thead class="text-c">
                                        <tr>
                                            <td class="myHead">
                                                <span>方案名称</span>
                                                <br>
                                                <span>编码位数</span>
                                            </td>
                                            <td>地市单位<i class="Hui-iconfont Hui-iconfont-manage c-blue" onclick="layer_show('客户单位编码','{{'/'.config('constant.name_admin').'/clientCode/index'}}')"></i></td>
                                            <td>区县单位<i class="Hui-iconfont Hui-iconfont-manage c-blue" onclick="layer_show('客户单位编码','{{'/'.config('constant.name_admin').'/clientCode/index'}}')"></i></td>
                                            <td>班站所码<i class="Hui-iconfont Hui-iconfont-manage c-blue" onclick="layer_show('客户单位编码','{{'/'.config('constant.name_admin').'/clientCode/index'}}')"></i></td>
                                            <td>电压等级码<i class="Hui-iconfont Hui-iconfont-manage c-blue" onclick="layer_show('电压等级编码','{{'/'.config('constant.name_admin').'/volCode/index'}}')"></i></td>
                                            <td>工具类别码<i class="Hui-iconfont Hui-iconfont-manage c-blue" onclick="layer_show('电压等级编码','{{'/'.config('constant.name_admin').'/sampleCode1/index'}}')"></i></td>
                                            <td>流水号</td>
                                            <td>数量</td>
                                            <td>序号</td>
                                        </tr>
                                        </thead>
                                        <tbody class="text-c">
                                        @foreach($gqjID_18_pros as $item)
                                        <tr>
                                            <td>{{$item['name']}}</td>
                                            <td>{{$item['city']}}</td>
                                            <td>{{$item['area']}}</td>
                                            <td>{{$item['ban']}}</td>
                                            <td>{{$item['vol']}}</td>
                                            <td>{{$item['tool']}}</td>
                                            <td>{{$item['serial']}}</td>
                                            <td>{{$item['sub_count']}}</td>
                                            <td>{{$item['sub_num']}}</td>
                                        </tr>
                                        @endforeach
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="row cl">
                                <label class="form-label col-sm-2">选择位数：</label>
                                <div class="formControls col-sm-9 skin-minimal">
                                    <div class="radio-box">
                                        <input type="radio" id="wei-1" name="set_other[gqjID_count][value]" value="18" {{data_get($setSys,'gqjID_count','') == 18 ? 'checked' :''}}>
                                        <label for="wei-1">只用18位流水码</label>
                                    </div>
                                    <div class="radio-box">
                                        <input type="radio" id="wei-2" name="set_other[gqjID_count][value]" value="24" {{data_get($setSys,'gqjID_count','') == 24 ? 'checked' :''}}>
                                        <label for="wei-2">国网24位编码</label>
                                    </div>
                                    <input type="hidden" name="set_other[gqjID_count][remark]" value="RFID编码-位数">
                                </div>
                            </div>
                            <div class="row cl">
                                <label class="form-label col-sm-2">选择流水码方案：</label>
                                <div class="formControls col-sm-9 skin-minimal">
                                    @foreach($gqjID_18_pros as $key=>$item)
                                        <div class="radio-box">
                                            <input type="radio" id="radio-{{$key}}" name="set_other[gqjID_pro][value]" value="{{$key}}" {{data_get($setSys,'gqjID_pro','') == $key ? 'checked' :''}}>
                                            <label for="radio-{{$key}}">{{$item['name']}}</label>
                                        </div>
                                    @endforeach
                                    <input type="hidden" name="set_other[gqjID_pro][remark]" value="RFID编码-流水码规则-方案号">
                                </div>
                            </div>
                        </div>
                    </div>
                    @csrf
                    <div class="row cl col-sm-9 col-sm-offset-3">
                        <a class="btn btn-primary radius form2Sub">&nbsp;&nbsp;提 交&nbsp;&nbsp;</a>
                    </div>
                </form>
            </div>
            <div class="tabCon">
                <form class="form form-horizontal" id="form3" autocomplete="off">
                    <div class="row cl">
                        <label class="form-label col-sm-3">数据：</label>
                        <div class="formControls col-sm-5">
                            <a class="btn btn-primary radius size-S" id="back_up">备份</a>
                            <a class="btn btn-danger radius size-S" id="restore">还原</a>
                            <a class="btn btn-primary radius hidden" id="downBack">下载</a>
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-sm-3">用户密码有效期：</label>
                        <div class="formControls col-sm-5">
                            <select class="select2" name="set_other[pwd_exp_month][value]">
                                @for($i = 1;$i<=12;$i++)
                                <option value="{{$i}}" {{array_get($setSys,'pwd_exp_month',3) == $i ? 'selected' :''}}>{{$i}}个月</option>
                                @endfor
                            </select>
                            <input type="hidden" name="set_other[pwd_exp_month][remark]" value="设置用户密码有效期（月）">
                        </div>
                    </div>
                    <div class="row cl col-sm-9 col-sm-offset-3">
                        <a class="btn btn-primary radius form2Sub">&nbsp;&nbsp;提 交&nbsp;&nbsp;</a>
                    </div>
                </form>
            </div>
        </div>

    </article>

    <script type="text/javascript">
        $(function () {
            $("#tab_demo").Huitab({
                index: localStorage.getItem('settingEditIndex',0),
            });
            $('.tabBar',"#tab_demo").on('click',function () {
                let index = $(this).children('span.current').index();
                localStorage.setItem('settingEditIndex',index);
            })
            var index2;

            $('.skin-minimal input').iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
                increaseArea: '20%'
            });

            $("#form").validate({
                rules: {
                    // name:{
                    //     required:true,
                    //     notSpace:true,
                    // },

                },
                // onkeyup:false,
                // focusCleanup:false,
                success: "valid",
                submitHandler: function (form) {
                    $(form).ajaxSubmit({
                        type: 'post',
                        url: "",//自己提交给自己可以不写url
                        //beforeSend  beforeSubmit

                        beforeSend: function () {
                            //0.4透明度 白色遮罩
                            index2 = layer.load(2, {shade: [0.3, '#fff']});
                        },
                        complete: function () {
                            layer.close(index2);
                        },
                        success: function (data) {
                            //判断添加结果
                            if (data === '1') {
                                // parent.window.location.reload();//刷新
                                // parent.table_reload(0);//0停留在当前页，1回到第一页
                                layer.msg('操作成功!', {icon: 1, time: 2000});
                                location.reload();
                                // layer_close();
                            } else {
                                layer.msg('操作失败!', {icon: 2, time: 2000});
                            }
                        },
                        error: function (data) {
                            ajax_error(data);
                        }
                    });
                }
            });

        });
        $('.form2Sub').on('click', function () {
            let formData = $(this).closest('form').serialize();
            ajax('post', '', formData);
        })
        $('#back_up').on('click', function () {
            ajax('get', 'backUp', '', backUpBak, 0);

            function backUpBak(res) {
                if (res.substring(0, 4) === 'http') {
                    $('#downBack').removeClass('hidden').attr('href', res);
                    layer.confirm('备份完成，点击右侧下载按钮进行下载！', {
                        btn: ['知道啦']
                    });
                } else {
                    layer.msg(res);
                }
            }
        })
        $('#restore').on('click', function () {
            layer.confirm('<b class="c-danger">当前操作有极大的危险存在，已取消！！！请联系技术员进行还原！！！</b>', {btn: ['确定'], title: '<b class="c-red">危险！！！</b>'})
        })
    </script>
@endsection